package com.dkm.ec.activity.repository.impl;

import com.dkm.base.core.helper.SpringHelper;
import com.dkm.base.db.persistence.dao.IQueryDao;
import com.dkm.biz.repository.AbstractRepository;
import com.dkm.ec.activity.domain.SecKillActivityConfig;
import com.dkm.ec.activity.persistence.dao.SecKillActivityConfigQueryDao;
import com.dkm.ec.activity.persistence.entity.SecKillActivityConfigPo;
import com.dkm.ec.activity.repository.SecKillActivityConfigRepository;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by fanjinyuan on 2017/8/12.
 */
@Repository
public class SecKillActivityConfigRepositoryImpl extends AbstractRepository<String, SecKillActivityConfigPo,SecKillActivityConfig> implements SecKillActivityConfigRepository {

    @Resource
    private SecKillActivityConfigQueryDao secKillActivityConfigQueryDao;

    @Override
    public SecKillActivityConfig newInstance() {
        SecKillActivityConfigPo po = new SecKillActivityConfigPo();
        SecKillActivityConfig config = SpringHelper.getBean(SecKillActivityConfig.class);
        config.setData(po);
        return config;
    }

    @Override
    public SecKillActivityConfig newInstance(SecKillActivityConfigPo po) {
        SecKillActivityConfig config = SpringHelper.getBean(SecKillActivityConfig.class);
        config.setData(po);
        return config;
    }

    @Override
    public List<SecKillActivityConfigPo> findTodayActivities() {
        return secKillActivityConfigQueryDao.findByKey("findTodayActivities", null);
    }

    @Override
    public SecKillActivityConfigPo get(String activityId) {
        return secKillActivityConfigQueryDao.get(activityId);
    }

    @Override
    protected IQueryDao<String, SecKillActivityConfigPo> getQueryDao() {
        return secKillActivityConfigQueryDao;
    }

}
